﻿package lobby
{
	import flash.display.MovieClip;
	import flash.display.SimpleButton;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import lobby.events.LobbyEvent;
	import lobby.GlobalVariables;
	
	/**
	 * ...
	 * @author Doan Nguyen Thuy Nha Truc (Bamboo)
	 */
	public class GameMenuPanel extends MovieClip
	{
		
		private var arrayLableBtn:Array;
		private var arrayBtn:Array;
		private var overColor:Number = 0xFFCC00;
		private var outColor:Number = 0xFFFFFF;
		
		public var menu_mc:SimpleButton;
		public var menuAll_mc:MenuHolder;
		public var menutext_mc:MovieClip;
		
		public var chTabletext_mc:MovieClip;
		
		public function GameMenuPanel()
		{
			menutext_mc.visible = false;
			//menutext_mc.menu_txt.text = "Menu";
			menutext_mc.mouseEnabled = false;
			menutext_mc.menu_txt.mouseEnabled = false;
			
			menuAll_mc.visible = false;
			
			menu_mc.addEventListener(MouseEvent.CLICK, menuClickHdl);
			menu_mc.addEventListener(MouseEvent.ROLL_OVER, menuOverHdl);
			menu_mc.addEventListener(MouseEvent.ROLL_OUT, menuOutHdl);
		
		}
		
		public function initText()
		{
			trace("init text ==================== : " + GlobalVariables.langInfo.hashTable.lookupString("lblMenu"));
			menutext_mc.visible = true;
			menutext_mc.menu_txt.text = GlobalVariables.langInfo.hashTable.lookupString("lblMenu");
		}
		
		public function menuOverHdl(e:MouseEvent):void
		{
			menuAll_mc.x = menu_mc.x - menu_mc.width / 2;
			menuAll_mc.y = menu_mc.y;
			menuAll_mc.visible = true;
		}
		
		public function menuOutHdl(e:MouseEvent):void
		{
			menuAll_mc.visible = false;
		}
		
		public function menuClickHdl(e:MouseEvent):void
		{
		
		}
		
		/**
		 * @author Bamboo
		 * @param	e
		 */
		private function hdlBtnClick(e:MouseEvent):void
		{
			trace("anem:" + e.currentTarget.name);
			//sendInfoMainGame(e.currentTarget.name);
		
			//khai
			//var event:LobbyEvent = new LobbyEvent(LobbyEvent.SET_MENU_GAME, true);
			//event.ms = e.currentTarget.name;
			//dispatchEvent(event);
		
		}
		
		private function hdlBtnRollOver(e:MouseEvent):void
		{
			
			var leng:int = arrayBtn.length;
			for (var i:int = 0; i < leng; i++)
			{
				if (arrayBtn[i] == e.currentTarget)
				{
					arrayLableBtn[i].textColor = overColor;
					break;
				}
			}
		
		}
		
		private function hdlBtnRollOut(e:MouseEvent):void
		{
			var leng:int = arrayBtn.length;
			for (var i:int = 0; i < leng; i++)
			{
				if (arrayBtn[i] == e.currentTarget)
				{
					arrayLableBtn[i].textColor = outColor;
					break;
				}
			}
		}
		
		public function sendInfoMainGame(nameObj:String):void
		{
			MovieClip(parent).receiverInfoFromMenu(nameObj);
			//trace("ok");
		}
	
	}

}